package iteratorPattern.demo;

import java.util.Iterator;
import java.util.List;

/**
 * @author： pang-yun
 * @date： 2021-12-10 10:01
 * 功能目的 ：用于
 */

public class OutPutImpl {
    // 学院集合
    List<College>  collegeList;

    public OutPutImpl(List<College> collegeList) {
        this.collegeList = collegeList;
    }

    public void printCollege(){
        Iterator<College> iterator = collegeList.iterator();
        while (iterator.hasNext()){
            College college = iterator.next();
            System.out.println("学院名称"+college.getName());
            printDepartment(college.createIterator());
        }
    }

    // 输出学院 输出系
    public void printDepartment(Iterator iterator){
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
    }
}
